<?php

use yii\bootstrap\Modal;
use yii\helpers\Html;
use yii\helpers\Url;
use yii\web\JsExpression;
use yii\widgets\ActiveForm;
use kartik\select2\Select2;

/* @var $this yii\web\View */
/* @var $model backend\models\Svn */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="svn-form">

    <?php $form = ActiveForm::begin(); ?>

    <?php
    echo $form->field($model, 'patch_id')->widget(Select2::class, [
        'options'       => ['placeholder' => '请输入标题名称 ...', ],
        'pluginOptions' => [
            'placeholder'       => 'search ...',
            'allowClear'        => true,
            'language'          => [
                'errorLoading' => new JsExpression("function () { return 'Waiting...'; }"),
            ],
            'ajax'              => [
                'url'      => \yii\helpers\Url::to(['patch/search-title']),
                'dataType' => 'json',
                'data'     => new JsExpression('function(params) { return {q:params.term}; }'),
            ],
            'escapeMarkup'      => new JsExpression('function (markup) { return markup; }'),
            'templateResult'    => new JsExpression('function(res) { return res.text; }'),
            'templateSelection' => new JsExpression('function (res) { return res.text; }'),
        ],
    ]);
    ?>

    <?= $form->field($model, 'code')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'comment')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'detail')->widget(\crazydb\ueditor\UEditor::class) ?>

    <?= $form->field($model, 'environment')->dropDownList($model->environmentList) ?>

    <!--
    <?//= $form->field($model, 'file')->checkboxList(\backend\models\File::dropDownList()) ?>
    -->

    <div class="form-group">
        <?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?>
    </div>

    <?php ActiveForm::end(); ?>

</div>

